搜索 K
Appearance
博客正在加载中...
Appearance
学了这么多 Nginx 的命令后,是时候总结一下 Nginx 的命令了,作为一个命令手册。
Linux 下:
./nginxWindows 下:nginx -v
Linux 下:
./nginxWindows 下:
Linux
Windows 下:
Windows 下:
为了方便,我们可以做一个启停菜单,方便运维:nginx_menu.sh
url=/opt/nginx # Nginx安装位置
cd ${url}/sbin
while true
do
read -p "
1.启动Nginx
2.停止Nginx
3.重启Nginx
4.强制停止Nginx
5.查询Nginx进程
0.退出
请输入:" input
if [ $input = '1' ]; then
./nginx -c ${url}/conf/nginx.conf
echo 'Nginx 启动成功'
elif [ $input = '2' ]; then
./nginx -s quit
echo 'Nginx 停止成功'
elif [ $input = '3' ]; then
./nginx -s reload
echo 'Nginx 重启成功'
elif [ $input = '4' ]; then
pkill -9 nginx
echo 'Nginx 强制停止成功'
elif [ $input = '5' ]; then
prop=$(cat ${url}/nginx.pid) # pid文件所在位置,可以在nginx.conf里配置
result=$(ps -aux | grep ${prop} | wc -l)
if [ $result -lt 2 ]; then
echo 'nginx运行进程,状态:异常!'
else
echo '进程:'${prop}', Nginx 运行进程,状态:正常'
fi
elif [ $input = '0' ]; then
break;
fi;
done;